# coding:utf-8
import sys
from PySide6.QtCore import Qt
from PySide6.QtGui import QIcon
from PySide6.QtWidgets import QApplication

from qfluentwidgets import SplitFluentWindow, FluentIcon, NavigationAvatarWidget, NavigationItemPosition, setTheme, Theme
from APP.H510Test.Focus_Interface_H510TestForm import FocusInterface_H510Test
from APP.HYB01Power.Focus_Interface_HYB01PowerForm import FocusInterface_HYB01Power
from APP.UltrasonicDetectionModule.Focus_interface_UltrasonicDetectionModule import FocusInterface_UltrasonicDetectionModule
from APP.XYMeshYH.Focus_Interface_XYMeshYH import FocusInterface_XYMeshYongHeng


class vTest(SplitFluentWindow):
    def __init__(self):
        super().__init__()
        self.setWindowTitle('软件测试平台')
        self.setWindowIcon(QIcon('./resource/icon.png'))
        self.setMinimumWidth(900)
        self.setMinimumHeight(680)

        # 添加子界面-H510Test
        self.H510TestFocusInterface = FocusInterface_H510Test(self)
        self.addSubInterface(self.H510TestFocusInterface, FluentIcon.RINGER, '510速度控制测试')

        # 添加子界面-HYB01PowerForm
        self.HYB01PowerFocusInterface = FocusInterface_HYB01Power(self)
        self.addSubInterface(self.HYB01PowerFocusInterface, FluentIcon.RINGER, 'HYB01电源管理板测试')

        # 添加子界面-UltrasonicDetectionModule
        self.UltrasonicDetectionModuleInterface = FocusInterface_UltrasonicDetectionModule(self)
        self.addSubInterface(self.UltrasonicDetectionModuleInterface, FluentIcon.RINGER, '4超声波探测模块测试')

        # 添加子界面-XYMeshYH
        self.XYMeshyh = FocusInterface_XYMeshYongHeng(self)
        self.addSubInterface(self.XYMeshyh, FluentIcon.MEDIA, '咏恒双轴倾角传感器')

        self.navigationInterface.addWidget(
            routeKey='avatar',
            widget=NavigationAvatarWidget('Abaddon', './resource/avatar.png'),
            position=NavigationItemPosition.BOTTOM
        )

        self.navigationInterface.addItem(
            routeKey='setting',
            icon=FluentIcon.SETTING,
            text='设置',
            position=NavigationItemPosition.BOTTOM
        )
        # self.focusInterface.ThemeCombo_box.currentTextChanged['QString'].connect(self.OnSelectTheme)    # type: ignore
        # self.focusInterface.ThemeSignal.connect(self.OnSelectTheme)     # type: ignore

    def closeEvent(self, a0):
        self.H510TestFocusInterface.closeEvent(None)
        self.HYB01PowerFocusInterface.closeEvent(None)
        self.UltrasonicDetectionModuleInterface.closeEvent(None)
        self.clearFocus()
        self.close()

if __name__ == '__main__':
    QApplication.setHighDpiScaleFactorRoundingPolicy(Qt.HighDpiScaleFactorRoundingPolicy.PassThrough)
    setTheme(Theme.DARK)
    app = QApplication(sys.argv)
    w = vTest()
    w.show()
    app.exec()
